﻿using System;

namespace Program05._1
{
    class Program
    {
        static void Main(string[] args)
        {

            //性别
            string gender;
            //身高
            int height;
            //体重
            int weight;

            Console.WriteLine("请输入您的性别（男/女）：");
            gender = Console.ReadLine();

            //判定用户输入的并别是否合法           
            while(!(gender=="男"||gender=="女"))
            {
                Console.WriteLine("您的输入不合法，请重新输入！");
                gender = Console.ReadLine();
            }
            //判定用户输入的身高
            Console.WriteLine("请输入您的身高（cm）：");
            while(!int.TryParse(Console.ReadLine(),out height)&&height>50)
            {
                Console.WriteLine("您输入的身高不正确，请重新输入!");
            }
            //判定用户输入的体重
            Console.WriteLine("请输入您的体重（kg）：");
            while (!int.TryParse(Console.ReadLine(), out weight) && weight >20)
            {
                Console.WriteLine("您输入的体重不正确，请重新输入!");
            }
            //输入判断健康的结果信息
            string message = "";
            message = DetactWeight(GetStandardWeight(gender, height, weight), weight);
            Console.WriteLine("您的健康状况是：" + message);       
        }
        /// <summary>
        /// 计算标准体重
        /// </summary>
        /// <param name="gender"></param>
        /// <param name="height"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public static int GetStandardWeight(string gender,int height,int weight)
        {
            int standardWeight;
            if(gender=="男")
            {
                //男士标准体重
                standardWeight = (height - 80) * 7 / 10;
            }
            else
            {
                //女士标准体重
                standardWeight = (height - 70) * 6 / 10;
            }
            return standardWeight;
        }
        /// <summary>
        /// 检查健康状况
        /// </summary>
        /// <param name="standardWeight"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public static string DetactWeight(int standardWeight,int weight)
        {
            string message = "";
            if(weight-standardWeight>0)
            {
                //体重正常，体重过重，过于肥胖
                if (weight < standardWeight * 11 / 10)
                    message = "体重正常";
                else
                {
                    if (weight > standardWeight * 11 / 10 && weight < standardWeight * 12 / 10)
                        message = "体重过重";
                    else
                        message = "过于肥胖";
                }
            }
            else
            {
                //体重正常，体重过轻，体重不足
                if (weight < standardWeight * 9 / 10)
                    message = "体重正常";
                else
                {
                    if (weight > standardWeight * 9 / 10 && weight < standardWeight * 8 / 10)
                        message = "体重过轻";
                    else
                        message = "体重不足";
                }
            }

            return message;
        }
    }
}
